#ifndef _REPEATEDNUMBER_H
#define _REPEATEDNUMBER_H

template <typename T>
T FindNumberMoreThanHalfRepeated(T arr[],int n)
{
    T key=arr[0];
    int rep=1;
    for(int i=2;i<n;i++)
    {
        if(rep==0)
        {
            rep++;
            key=arr[i];
            continue;
        }
        else
        {
            if(arr[i]==key)
               rep++;
            else
            {
                rep--;
            }
        }
    }
    return key;
}

#endif